﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<QLDAOL.ModelView.RegisterModel>" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Register</title>
</head>
<body>
    <div>
    <script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script>
    <script src="../../Scripts/MicrosoftMvcValidation.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery-1.7.js" type="text/javascript"></script>
    <script src="../../Scripts/xcaptcha-2.0.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        jQuery(document).ready(function () {
            $("#password").blur(function () {

                var pwd = this.value;
                // alert(pwd);
                var Mcolor = "#FFF", Lcolor = "#FFF", Hcolor = "#FFF";
                var m = 0;
                var Modes = 0;
                for (i = 0; i < pwd.length; i++) {
                    var charType = 0;
                    var t = pwd.charCodeAt(i);
                    if (t >= 48 && t <= 57) {
                        charType = 1;
                    }
                    else if (t >= 65 && t <= 90) {
                        charType = 2;
                    }
                    else if (t >= 97 && t <= 122)
                        charType = 4;
                    else
                        charType = 4;
                    Modes |= charType;
                }
                for (i = 0; i < 4; i++) {
                    if (Modes & 1) m++;
                    Modes >>>= 1;
                }
                if (pwd.length <= 4) {
                    m = 1;
                }
                switch (m) {
                    case 1:
                        Lcolor = "2px solid red";
                        Mcolor = Hcolor = "2px solid #DADADA";
                        break;
                    case 2:
                        Mcolor = "2px solid #f90";
                        Lcolor = Hcolor = "2px solid #DADADA";
                        break;
                    case 3:
                        Hcolor = "2px solid #3c0";
                        Lcolor = Mcolor = "2px solid #DADADA";
                        break;
                    case 4:
                        Hcolor = "2px solid #3c0";
                        Lcolor = Mcolor = "2px solid #DADADA";
                        break;
                    default:
                        Hcolor = Mcolor = Lcolor = "";
                        break;
                }
                if (document.getElementById("pwd_lower")) {
                    document.getElementById("pwd_lower").style.borderBottom = Lcolor;
                    document.getElementById("pwd_middle").style.borderBottom = Mcolor;
                    document.getElementById("pwd_high").style.borderBottom = Hcolor;
                }


            });
            $("#username").blur(function () {

                var user = this.value;
                alert(user);
                if (user != "") {
                    $.post("/account/is_register", { user: user }, function (data) {
                        // alert(data);
                        if (data == -1) {
                            document.getElementById('check').innerHTML = "* Tài khoản này đã tồn tại, xin vui lòng nhập lại.";
                            document.getElementById('btn_reg').disabled = 'Disable';

                        }
                        else {
                            document.getElementById('check').innerHTML = "√&nbsp;Được phép đăng ký";
                            document.getElementById('btn_reg').disabled = '';
                        }

                    });
                }
            });
        });
        
    </script>
  <% Html.EnableClientValidation(); %>
 
  	
	<div class="block">
		<div class="loginbox blank">
		<span class="lt"></span>
		<span class="lb"></span>
		<span class="rt"></span>
		<span class="rb"></span>
		<h5>
			<p class="regbg" >Đăng ký</p>
           
		</h5>
        <div style="margin-left:120px; color:Red; font-size:20px;">
         <%= Html.ValidationSummary(true, "Đăng kí thất bại. Kiểm tra lại thông tin") %>
        </div>
          
		<% using (Html.BeginForm())
     { %>
			<table width="100%" cellspacing="5" cellpadding="3" border="0" align="left">
				<tbody>
					<tr>
						<td width="40%" align="right">
						Tài Khoản(
						<font color="red">*</font>
						)
                       
						</td>
						<td width="20%" align="left">
						<%: Html.TextBoxFor(r => r.username)%>
						<font id="username_notice" style="color:#FF0000"> *</font>
						</td>
                        <td width="40%" align="left">
                        
                        <div id="check"><%: Html.ValidationMessageFor(r => r.username)%></div>
                        
                        </td>
					</tr>
					<tr>
						<td align="right">
						Email(
						<font color="red">*</font>
						)
						</td>
						<td>        
						<%: Html.TextBoxFor(r => r.email)%>
						<font id="email_notice" style="color:#FF0000"> *</font>
						</td>
                         <td>
                        <%: Html.ValidationMessageFor(r => r.email)%>
                        </td>
					</tr>
					<tr>
						<td align="right">
						Mật khẩu(
						<font color="red">*</font>
						)
						</td>
						<td>
                        <div><%: Html.PasswordFor(r => r.password)%>
						<font id="password_notice" style="color:#FF0000"> *</font></div>
						
						</td>
                         <td>
                        <%: Html.ValidationMessageFor(r => r.password)%>
                        </td>
					</tr>
					<tr>
						<td align="right">Độ mạnh mật khẩu</td>
						<td colspan=2>
						<table width="145" cellspacing="0" cellpadding="1" border="0">
							<tbody>
							<tr align="center">
								<td id="pwd_lower" width="33%">Yếu </td>
								<td id="pwd_middle" width="33%">Trung bình</td>
								<td id="pwd_high" width="33%">Mạnh</td>
							</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td align="right">
						Xác nhận mật khẩu(
						<font color="red">*</font>
						)
						</td>
						<td>
							<%: Html.PasswordFor(r => r.confirm)%>
						<font id="conform_password_notice" style="color:#FF0000"> *</font>
						</td>
                            <td>
                        <%: Html.ValidationMessageFor(r => r.confirm)%>
                        </td>
					</tr>
                   
                     	
					<tr>
						<td align="right">
						Mã xác nhận:&nbsp;
						<br/>
						(Kích chuột vào mã nếu bạn muốn đổi)
						</td>
						<td>
						<%=Html.TextBoxFor(cd => cd.Attempt)%><%=Html.ValidationMessageFor(cd => cd.Attempt)%>
						
      
						</td>
                         <td>
                   <%: Html.XCaptcha().Image(m => m.EncrypedSolution)%>
                        </td>
					</tr>
					<tr>
                    <%: Html.AntiForgeryToken()%>
						<td>&nbsp;</td>
						<td colspan= "2">
						
						</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
						<td align="left">
						<input type="hidden" value="act_register" name="act" />
						<input type="hidden" value="" name="back_act" />
						<input class="bnt_login" type="submit" value="Register" id="btn_reg" name="btn_reg" disabled="disabled" />
						</td>
                        <td>&nbsp;</td>
					</tr>
                    <tr>
                        <td colspan="3">&nbsp;</td>
                     </tr>
                     <tr>
                                <td>&nbsp;</td>
                        <td class="actionSub">
                                <a class="txtdot" href="/account/logon">
                                Bạn đã có tài khoản?&gt;&gt;
                                <b>
                                <u>Đăng Nhập</u>
                                </b>
                                </a>
                                <br>
                        </td>
                          <td>&nbsp;</td>
                    </tr>
                    <tr>
                    <td>&nbsp;</td>
                    <td colspan="2">
                   
                    </td>
                    </tr>
				</tbody>
			</table>
          
		<% } %>
        
		</div>
         
	</div>
	<%--<script charset="utf-8" type="text/javascript">

            
        

       function xcaptchaChangeCaptchaImage()
       {
           var solutionUrl = "<%: Url.Action("EncryptedCaptchaSolution")%>";
           var imageUrl  = "<%= Url.Action("CaptchaImage")%>" + "?solution="
           
           xcaptchaSetCaptchaImage(solutionUrl,imageUrl);
       };
      

//    $(document).ready(function () {
//    xcaptchaChangeCaptchaImage();

//    });
    </script> --%> 
   <script type="text/javascript">
       function xcaptchaChangeCaptchaImage() {
           var s = '/Account/EncryptedCaptchaSolution';
           var i = '/Account/CaptchaImage?encryptedSolution=';
           xcaptchaSetCaptchaImage(s, i);
       };
       jQuery(document).ready(function () {
           xcaptchaChangeCaptchaImage();
           $('#-xcaptcha-refresh').click(function () {

              
               xcaptchaChangeCaptchaImage();
               return false;

           });
       
       });
</script>
    </div>
</body>
</html>
